package dfbz.数组排序;

public class Test01 {
    public static void main(String[] args) {
        int[] arr={5,4,3,1,2};
        bubbling(arr);
        for (int i = 0; i <arr.length ; i++) {
            System.out.print(arr[i]+" ");
        }
    }
    public static int[] bubbling(int[] arr){
        int minIndex;
        int temp;
        for (int i = 0; i <(arr.length-1) ; i++) { //控制的是拿谁去比较
            minIndex=i;
            for (int j = i+1; j <arr.length ; j++) {
                if(arr[j]<arr[minIndex]){
                    minIndex=j;
                }
            }
            temp=arr[i];
            arr[i]=arr[minIndex];
            arr[minIndex]=temp;
        }
        return arr;
    }
}
